package com.xiaoqiang.servlet;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class DeleteArticle extends HttpServlet {
    public DeleteArticle() {
        super();
    }

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		System.out.println("成功陈宫城成功！");
/*		Connection conn = null;
		Statement stmt = null;
		try {
			// 加载驱动
			Class.forName("com.mysql.jdbc.Driver");
			// 获得链接
			conn = DriverManager.getConnection(
					"jdbc:mysql://localhost/demo?useSSL=true&"  
                    + "user=root&password=root"  
                    + "&useUnicode=true&characterEncoding=UTF8");
			// 获得语句对象
			stmt = conn.createStatement();
			// 执行SQL语句
			String sql = "insert into article(title,article) values ('"+title+"', '"+article+"')";
			System.out.println("sql : " + sql);
			stmt.executeUpdate(sql);
			System.out.println("成功");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			if (stmt != null) {
				try {
					stmt.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}

			if (conn != null) {
				try {
					conn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}*/
		
		
//		request.getRequestDispatcher("articleList.jsp").forward(request, response);
	}


	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
